import { getAddressList, reqOrderInfo } from '@/api/trade'

const state = {
  userAdress: [],
  orderInfo: {}
}
const mutations = {
  SET_USER_ADRESS (state, payload) {
    state.userAdress = payload
  },
  SET_ORDER_INFO (state, payload) {
    state.orderInfo = payload
  }
}
const actions = {
  // 获取用户地址
  async getUserAdress ({ commit }) {
    const res = await getAddressList()
    //    console.log('res:', res)
    if (res.code === 200) {
      commit('SET_USER_ADRESS', res.data)
    }
  },
  //   获取商品清单数据
  async getOrderInfo ({ commit }) {
    const res = await reqOrderInfo()
    console.log('res:', res)
    if (res.code === 200) {
      commit('SET_ORDER_INFO', res.data)
    }
  }
}
const getters = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
